home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Source Code / C / Applications / µSim 1.0.5 / FabLibsƒ / FabTaskManager.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-11-17  |  1.2 KB  |  77 lines  |  [TEXT/CWIE]

  1. #include    "FabTaskManager.h"
  2. #include    "FabWmemman.h"
  3.  
  4. enum {
  5. fabQueueType = 25
  6. };
  7.  
  8. //static NMUPP sNMUPP = nil;
  9. static QHdr    sQueueHdr = { 0, nil, nil};
  10.  
  11. static void myResponse(TMInfoPtr theTaskPtr);
  12.  
  13. void myResponse(TMInfoPtr theTaskPtr)
  14. {
  15. void (*proc)(long);
  16. long    param;
  17.  
  18. #if    GENERATING68K
  19. long    oldA5;
  20.  
  21. oldA5 = SetA5((long)theTaskPtr->savedA5);
  22. #endif
  23.  
  24. (void) Dequeue((QElemPtr)theTaskPtr, &sQueueHdr);
  25. param = theTaskPtr->parameter;
  26. proc = theTaskPtr->tmProc;
  27. ffree(theTaskPtr);
  28. proc(param);
  29.  
  30. #if    GENERATING68K
  31. (void) SetA5(oldA5);
  32. #endif
  33. }
  34.  
  35. void InitTaskManager(void)
  36. {
  37. //sNMUPP = NewNMProc(myResponse);
  38. }
  39.  
  40. void PROCCALLEDATINTERRUPTTIME(TMInfoPtr theTaskPtr, long param)
  41. {
  42. #if    GENERATING68K
  43. long    oldA5;
  44. #endif
  45.  
  46. theTaskPtr->parameter = param;
  47.  
  48. #if    GENERATING68K
  49. oldA5 = SetA5((long)theTaskPtr->savedA5);
  50. #endif
  51.  
  52. (void) Enqueue((QElemPtr)theTaskPtr, &sQueueHdr);
  53.  
  54. #if    GENERATING68K
  55. (void) SetA5(oldA5);
  56. #endif
  57. }
  58.  
  59. void InitTaskRecord(void (*theProc)(long), TMInfoPtr theTaskPtr)
  60. {
  61. theTaskPtr->qType = fabQueueType;
  62. theTaskPtr->tmProc = theProc;
  63. //theTaskPtr->respProc = myResponse;
  64.  
  65. #if    GENERATING68K
  66. theTaskPtr->savedA5 = LMGetCurrentA5();
  67. #endif
  68. }
  69.  
  70. void CheckCallQueue(void)
  71. {
  72. TMInfoPtr    head;
  73.  
  74. while (head = (TMInfoPtr)sQueueHdr.qHead)
  75.     myResponse(head);
  76. }
  77.